<?php
/**
 * Lists
 * Created by Veyron
 * motto:现在的拼搏 为了更好的明天
 * day:  2020/3/23
 * Time: 21:54
 */

namespace app\api\controller\mall;

use app\api\controller\ApiBase;
use app\common\lib\Show;
use app\common\business\Goods as goodsBis;

class Lists extends ApiBase
{
    public function index(){
        $pageSize   = input('param.page_size','0','intval');
        $categoryId = input('param.category_id','0','intval');
        $keyword    = input('param.keyword','','trim');

        if(!$categoryId && !$keyword){
            return Show::success();
        }
        $data = [
            'category_path_id' => $categoryId
        ];
        if($keyword){
            $data['keyword'] = $keyword;
        }
        $field = input('param.field','listorder','trim');
        $order = input('param.order',2,'intval');
        $order = $order == 2 ? 'desc' : 'asc';
        $order = [$field => $order];
        $goods = (new GoodsBis())->getNormalLists($data, $order, $pageSize);
        return Show::success($goods);
    }
}
